cmake_minimum_required(VERSION 3.8)
project(2_cpp_base)


if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic -g3 -O0)
endif()

find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
find_package(common REQUIRED)

add_executable(talker src/1_topic_public.cc)
ament_target_dependencies(talker rclcpp std_msgs)

add_executable(listener src/2_topic_subscriber.cc)
ament_target_dependencies(listener rclcpp std_msgs)

add_executable(3_ros2_topic_selfMsg_Pub src/3_ros2_topic_自定义msg发布.cc)  # cmake可执行文件 不支持中文名
ament_target_dependencies(3_ros2_topic_selfMsg_Pub rclcpp std_msgs common) # 影响头文件

add_executable(4_ros2_topic_selfMsg_Sub src/4_ros2_topic_自定义msg订阅.cc)
ament_target_dependencies(4_ros2_topic_selfMsg_Sub rclcpp std_msgs common)

add_executable(5_ros2_service_server src/5_ros2_service_服务端.cc)
ament_target_dependencies(5_ros2_service_server rclcpp std_msgs common)

add_executable(6_ros2_service_client src/6_ros2_service_客户端.cc)
ament_target_dependencies(6_ros2_service_client rclcpp std_msgs common)

add_executable(7_ros2_topic_public_address_book src/7_ros2_topic_发布AddressBook.cc)
ament_target_dependencies(7_ros2_topic_public_address_book rclcpp std_msgs common)

add_executable(8_ros2_topic_pub_Contact src/8_ros2_topic_发布Contact.cc)
ament_target_dependencies(8_ros2_topic_pub_Contact rclcpp std_msgs common)

add_executable(9_ros2_param_get_set_example src/9_ros2_param_get_set实例.cc)
ament_target_dependencies(9_ros2_param_get_set_example rclcpp std_msgs common)

add_executable(11_QoS_topic_pub src/11_QoS_topic_发布.cc)
ament_target_dependencies(11_QoS_topic_pub rclcpp std_msgs common)

add_executable(12_QoS_topic_sub src/12_QoS_topic_订阅.cc)
ament_target_dependencies(12_QoS_topic_sub rclcpp std_msgs common)

add_executable(31_log_output src/31_log_日志输出.cc)
ament_target_dependencies(31_log_output rclcpp std_msgs common)

add_executable(32_ros2_log_manage src/32_ros2_log_管理.cc)
ament_target_dependencies(32_ros2_log_manage rclcpp std_msgs common rcl_logging_spdlog)

# add_executable(33_ros2_logging_size_backup_name src/33_ros2_logging_文件大小_备份数量_文件名_设置.cc) --无效API
# ament_target_dependencies(33_ros2_logging_size_backup_name rclcpp std_msgs common)

install(TARGETS
  talker
  listener
  3_ros2_topic_selfMsg_Pub
  4_ros2_topic_selfMsg_Sub
  5_ros2_service_server
  6_ros2_service_client
  7_ros2_topic_public_address_book
  8_ros2_topic_pub_Contact
  9_ros2_param_get_set_example
  11_QoS_topic_pub
  12_QoS_topic_sub
  31_log_output
  32_ros2_log_manage
  # 33_ros2_logging_size_backup_name
  DESTINATION lib/${PROJECT_NAME})

install(
  DIRECTORY launch
  DESTINATION share/${PROJECT_NAME}
)

install(FILES
  scripts/start.sh
  scripts/stop.sh
  DESTINATION share/..
  PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)

ament_package()
